package eco2automotive.tasks;
import eco2automotive.port.ConnectionControl;
import eco2automotive.gui.InforAlert;
import eco2automotive.elmFilter.Filter;
import eco2automotive.elmFilter.SpecialFormula;
import eco2automotive.lang.EN;
/** 
 * Standar OBD supported by the car
  * @version 1.0
  * @autor Fco. Javier Sánchez Esparza
  *
  */ 
public class Task_ConformsTo {
    ConnectionControl connControl;  
       
    /**
     * Take the control
     * @param connControl
     */
    public Task_ConformsTo(ConnectionControl connControl){
       this.connControl=connControl;       
           
       }
       
       /**
        * start
        */
       public void run(){           
        this.connControl.TXData("011C");                                              
        String str_p010C="";
        try{Thread.sleep(3000);}catch(Exception e){}                                            
     if (connControl.DATA_AVAILABLE()==false)
      {   //NO RESPONSE      
      new InforAlert("#ERROR!",EN.QUICK_ACTIONS_QUERY_NO_RESPONSE,1).showAlert();                            
        }
     else{
        for(int i=0;i<=connControl.getFata().getLength();i++){  //FOR  --------------------------------------
            String data=connControl.getFata().extract().toString();  //Searching data          
            str_p010C=new Filter().getDigest(data,"411C[0-9-A-Z]{2}");                                                                            

        }
         if(!str_p010C.isEmpty()){
             String standar=new SpecialFormula().pid_011C(str_p010C);
             standar=standar.substring(4);//substract the 411C head
             new InforAlert("#P010C",EN.QUICK_ACTIONS_PROTOCOL_CONFORMS+standar,2).showAlert();                                              
         }
         //this.connControl.downFlag();
       }
       } //run()
}
